|
|
|
|
|
|
|
Listing 9.16. Coding the cmdModifyTable_Click event. |
|
|
|
|
|
|
|
|
Private Sub cmdModifyTable_Click()
'
' modify an existing table
'
On Error Resume Next
'
Dim ws As Workspace
Dim db As Database
Dim td As TableDef
Dim fl As Field
'
Dim strDBName As String
Dim strTDName As String
Dim strFLName As String
Dim intFLType As Integer
Dim strMsg As String
'
' init vars
strDBName = App.Path & "\NewDB.mdb"
strTDName = "NewTable"
strFLName = "FollowDate"
intFLType = dbDate
'
' first create table with other subroutine
cmdCreateTable_Click
'
' now open ws & db & td
Set ws = DBEngine.Workspaces(0)
Set db = OpenDatabase(strDBName)
Set td = db.TableDefs(strTDName)
'
' add a new field
Set fl = td.CreateField(strFLName, intFLType)
td.Fields.Append fl
'
' make list of fields
strMsg = "Appended Field:"
For Each fl In td.Fields
strMsg = strMsg & vbTab & fl.Name & vbCrLf
Next
'
' now delete the new field
td.Fields.Delete strFLName
'
' make list again
strMsg = strMsg & "Deleted Field:"
For Each fl In td.Fields
strMsg = strMsg & vbTab & fl.Name & vbCrLf
Next
' |
|
|
|
|
|